﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace HualongExcel.Froms
{
    public partial class AboutForm : Form
    {

        private static AboutForm formIns;

        public static AboutForm FormIns
        {
            get
            {

                if (formIns == null || formIns.IsDisposed)
                    formIns = new AboutForm();
                return formIns;
            }
        }

        #region 窗体方法
        public static void ShowSignleForm(bool isDialogue)
        {


            if (isDialogue)
                FormIns.ShowDialog();
            else
                FormIns.Show();

        }
        public static void HideSignleForm()
        {
            FormIns.Hide();
        }

        public static void DisposeSignleForm()
        {
            FormIns.Dispose();
        }
        #endregion

        public AboutForm()
        {
            InitializeComponent();
        }

        private void AboutForm_Load(object sender, EventArgs e)
        {
            this.Left = Screen.PrimaryScreen.Bounds.Width / 2 - this.Width / 2;//桌面的宽度的一半减去自身宽的的一半
            this.Top = Screen.PrimaryScreen.Bounds.Height / 2 - this.Height / 2;//桌面的高度的一半减去自身高度的一半
      

            AboutLabel.Text = $"HualongExcel\n基于模板生成的Excel电子表格处理程序\n杭州华隆制冷工程有限公司内部程序\n版本:{System.Reflection.Assembly.GetExecutingAssembly().GetName().Version}";
        }

        protected override void OnResize(EventArgs e)
        {
            base.OnResize(e);
            int offset=0;

            offset = this.Width / ConfirmButton.Width;
            ConfirmButton.Left = (this.Width - (ConfirmButton.Width + offset)) / 2 - offset;

            offset = this.Width / LogoPictureBox.Width;
            LogoPictureBox.Left = (this.Width - (LogoPictureBox.Width + offset)) / 2 - offset;


            offset = this.Width / AboutLabel.Width;
            AboutLabel.Left = (this.Width - (AboutLabel.Width + offset)) / 2 - offset;
        }
        private void ConfirmButton_Click(object sender, EventArgs e)
        {
            DisposeSignleForm();

            
        }
    }
}
